package com.yimi.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.view.animation.LinearInterpolator;
import android.widget.ImageView;

public class FlippingImageView extends ImageView {
	 private ao a = null;
	 private boolean b = false;
	 private int c = 2;
	
	public FlippingImageView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public FlippingImageView(Context paramContext, AttributeSet paramAttributeSet, int paramInt){
		super(paramContext, paramAttributeSet, paramInt);
	}
	
	private void a()
	  {
	    if ((this.b) || (getWidth() <= 0) || (getVisibility() != 0))
	      return;
	    this.b = true;
	    if (this.a == null)
	    {
	      this.a = new ao(getWidth() / 2.0F, getHeight() / 2.0F, this.c);
	      this.a.setDuration(1000L);
	      this.a.setInterpolator(new LinearInterpolator());
	      this.a.setRepeatCount(-1);
	      this.a.setRepeatMode(1);
	    }
	    startAnimation(this.a);
	  }

	  private void b()
	  {
	    if (!this.b)
	      return;
	    this.b = false;
	    setAnimation(null);
	    this.a = null;
	  }

	  public final void a(int paramInt)
	  {
	    this.c = paramInt;
	    if (this.a == null)
	      return;
	    this.a.a(this.c);
	  }

	  protected void onAttachedToWindow()
	  {
	    super.onAttachedToWindow();
	    a();
	  }

	  protected void onDetachedFromWindow()
	  {
	    super.onDetachedFromWindow();
	    b();
	  }

	  protected void onSizeChanged(int paramInt1, int paramInt2, int paramInt3, int paramInt4)
	  {
	    super.onSizeChanged(paramInt1, paramInt2, paramInt3, paramInt4);
	    if (paramInt1 <= 0)
	      return;
	    a();
	  }

	  protected void onVisibilityChanged(View paramView, int paramInt)
	  {
	    if ((paramInt == 4) || (paramInt == 8))
	      b();
	    while (true)
	    {
	      a();
	      return;
	    }
	  }

	  public void setVisibility(int paramInt)
	  {
	    if ((paramInt == 4) || (paramInt == 8))
	      b();
	    while (true)
	    {
	      setVisibility(paramInt);
	      a();
	      return;
	    }
	  }
}
